﻿using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class StaticVarFunc : MonoBehaviour {
	/*public static StaticVarFunc SVF{
		get{ 
			if (StaticVarFunc.privateSVF == null) {
				StaticVarFunc.privateSVF = GameObject.FindObjectOfType<StaticVarFunc> ();
			}
			return StaticVarFunc.privateSVF;
		}
	}
	public static StaticVarFunc privateSVF;*/
	///玩家物体
	public static GameObject Player;
	[SerializeField] GameObject p_player;
	public static CharacterController characterCtrl;
	[SerializeField] CharacterController p_characterCtrl;
	public static UnityStandardAssets.Characters.FirstPerson.FirstPersonController firstCtrl;
	[SerializeField] UnityStandardAssets.Characters.FirstPerson.FirstPersonController p_firstCtrl;
	///玩家的眼睛
	public static GameObject PlayerEye;
	[SerializeField] GameObject p_playerEye;
	public static GameObject LeftEye;
	[SerializeField] GameObject p_leftEye;
	public static GameObject RightEye;
	[SerializeField] GameObject p_rightEye;
	///玩家左手
	public static GameObject leftHand;
	[SerializeField] GameObject p_leftHand;
	///玩家右手
	public static GameObject rightHand;
	[SerializeField] GameObject p_rightHand;

	///Boss
	public static GameObject Boss;
	[SerializeField] GameObject p_boss;
	///背包
	public static Backpack backpack;
	///存储了对话相关的<名字-物体>列表的脚本
	public static Talk_NamePosition namePos;
	[SerializeField] Talk_NamePosition p_NamePosition;


	void Awake(){
		StaticVarFunc.Player = p_player;
		StaticVarFunc.PlayerEye = p_playerEye;
		StaticVarFunc.LeftEye = p_leftEye;
		StaticVarFunc.RightEye = p_rightEye;
		StaticVarFunc.leftHand = p_leftHand;
		StaticVarFunc.rightHand = p_rightHand;
		StaticVarFunc.characterCtrl = p_characterCtrl;
		StaticVarFunc.firstCtrl = p_firstCtrl;
		StaticVarFunc.backpack = GameObject.FindObjectOfType<Backpack> ();
		StaticVarFunc.Boss = p_boss;
		StaticVarFunc.namePos = p_NamePosition;
	}
	/// <summary>
	/// 使对角色的控制为setEnable
	/// </summary>
	/// <param name="setEnable">If set to <c>true</c> set enable.</param>
	public static void SetPlayerControl(bool setEnable){
		StaticVarFunc.characterCtrl.enabled = setEnable;
		StaticVarFunc.firstCtrl.enabled = setEnable;
	}

}


//System.Convert.ToInt32 (minS [i])
/*
	/// <summary>
/// 判断现在的游戏流程是否在俩待比较流程之间
/// </summary>
/// <returns><c>true</c>, if game progress in was ised, <c>false</c> otherwise.</returns>
/// <param name="minProgress">流程下限.</param>
/// <param name="maxProgress">流程上限.</param>
public static bool isGameProgressIn(string minProgress, string maxProgress){
	if (StaticVarFunc.isBeforeGameProgress (minProgress) && !StaticVarFunc.isBeforeGameProgress (maxProgress)) {
		return true;
	} else {
		return false;
	}
}
public static bool isBeforeGameProgress(string minProgress){
	string[] minS = minProgress.Split ('-');
	string[] gameS = StaticVarFunc.gameProgress.Split ('-');
	for (int i = 0; i < minS.Length && i < gameS.Length; i++) {
		//如果游戏流程大于待比较流程，直接返回true
		if (System.Convert.ToInt32 (minS [i]) < System.Convert.ToInt32 (gameS[i])) {
			return true;
		} else if (System.Convert.ToInt32 (minS [i]) > System.Convert.ToInt32 (gameS[i])) {
			//如果游戏流程小于待比较流程，直接返回true
			return false;
		}
		//如果二者相同，进行下一步比较
	}
	//如果比较的部分都相同
	if (minS.Length <= gameS.Length) {
		return true;
	} else {
		return false;
	}
}*/